package org.idea.spring.jdbc.xa;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;

/**
 * @Author linhao
 * @Date created in 11:04 上午 2021/11/4
 */
public class JdbcTemplateTimeOutDemo {

    public static void main(String[] args) {
        DruidDataSource druidDataSource = (DruidDataSource) DruidTimeOutDemo.getDataSource();
        NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(druidDataSource);
        MapSqlParameterSource mapSqlParameterSource = new MapSqlParameterSource();
        mapSqlParameterSource.addValue("id",1);
        Integer result = jdbcTemplate.queryForObject("select count(1) from t_user",mapSqlParameterSource,Integer.class);
        System.out.println(result);
    }
}
